<?php

/**
 * BAMF.php
 *
 *
 * @author Application Support Group
 * @copyright University of Georgia
 * @package BAMF
 * @see Framework_Module
 * @filesource
*/


require_once( "PEAR.php" ) ;

/**
 * Determine whether this is a Windows or Unix environment
*/
if( !defined( 'FRAMEWORK_OS' )) {
	if( strtoupper( substr( PHP_OS, 0, 3 )) == 'WIN' ) {
		define( 'FRAMEWORK_OS', 'windows' ) ;
	} else {
		define( 'FRAMEWORK_OS', 'unix' ) ;
	}
}

// set the location of the NULL_FILE
switch( FRAMEWORK_OS ) {
	case 'unix' :
		if( !defined( 'NULL_FILE' )) { define ( 'NULL_FILE', '/dev/null' ) ; }
		ini_set( 'include_path', ini_get( 'include_path' ).":".dirname( __FILE__ )) ;
		break ;
	
	case 'windows' :
		if( !defined( 'NULL_FILE' )) { define ( 'NULL_FILE', 'NUL' ) ; }
		ini_set( 'include_path', ini_get( 'include_path' ).";".dirname( __FILE__ )) ;
		break ;
	
	default :
		die( "FRAMEWORK_OS is not properly defined." ) ;
		break ;
}// end switch


/**
 * __autoload
 *
 * Autoload is run by PHP when it can't find a class it is trying to load.
 * By naming our classes intelligently we should be able to load most classes
 * dynamically.
 *
*/

if ( !function_exists( '__autoload' )) {
	function __autoload($class) {
		$file = str_replace('_','/',$class.'.php'); 
	
		if( SHOW_DEBUG ) {
			include_once( $file ) ;
		} else {
			@include_once( $file ) ;
		}
	}
}



/**
 * APPLICATION CONSTANTS
*/
if( !defined( 'CONFIG_INI' )) define( 'CONFIG_INI', 'Config.ini' ) ;
if( !defined( 'APPLICATION_BASE_URL' )) define('APPLICATION_BASE_URL', "");
if( !defined( 'APPLICATION_BASE_PATH' )) define('APPLICATION_BASE_PATH', dirname( __FILE__ ));
if( !defined( 'FRAMEWORK_DSN' )) define('FRAMEWORK_DSN', 'mssql://username:password@my.host.edu,portnumb/dbname');
if( !defined( 'FRAMEWORK_DB_SCHEMA' )) define('FRAMEWORK_DB_SCHEMA', '');
if( !defined( 'FRAMEWORK_OCI_SEQUENCE_NAME' )) define( 'FRAMEWORK_OCI_SEQUENCE_NAME', 'oci_obj' ) ;
if( !defined( 'FRAMEWORK_SESSION_NAME' )) define( 'FRAMEWORK_SESSION_NAME', 'ASGSESSID' ) ;
if( !defined( 'FRAMEWORK_TIMESTAMP' )) define( 'FRAMEWORK_TIMESTAMP', time() ) ;
if( !defined( 'FRAMEWORK_DEFAULT_MODULE' )) define('FRAMEWORK_DEFAULT_MODULE', '');
if( !defined( 'FRAMEWORK_LOG_IDENT' )) define( 'FRAMEWORK_LOG_IDENT', 'bamf' ) ;
if( !defined( 'APPLICATION_DAO_NODE_PREFIX' )) define('APPLICATION_DAO_NODE_PREFIX', 'Dao_Node_');
if( !defined( 'DIE_ON_BAD_DSN' )) define('DIE_ON_BAD_DSN', false ) ;
if( !defined( 'DIE_ON_NULL_DSN' )) define('DIE_ON_NULL_DSN', false ) ;
if( !defined( 'BAD_DSN_REDIRECT_URL' )) define('BAD_DSN_REDIRECT_URL', null ) ;
if( !defined( 'APPLICATION_DAO_NODE_PREFIX' )) define('APPLICATION_DAO_NODE_PREFIX', 'Dao_Node_');
if( !defined( 'DEFAULT_AUTH_USER_FIELD' )) define('DEFAULT_AUTH_USER_FIELD', '');
if( !defined( 'DEFAULT_LOGIN_PATH' )) define('DEFAULT_LOGIN_PATH', '');


if( !defined( 'FRAMEWORK_LOG_FILE' )) define( 'FRAMEWORK_LOG_FILE', NULL_FILE ) ;
if( !defined( 'FRAMEWORK_LOG_TABLE' )) define( 'FRAMEWORK_LOG_TABLE', 'APPLICATION_LOG' ) ;
if( !defined( 'DB_ERROR_MODE' )) define( 'DB_ERROR_MODE', 'sql' ) ;
if( !defined( 'FILE_ERROR_MODE' )) define( 'FILE_ERROR_MODE', 'file' ) ;
if( !defined( 'ERROR_HANDLER_MODE' )) define( 'ERROR_HANDLER_MODE', FILE_ERROR_MODE ) ;



# Flags to toggle debug mode
if( !defined( 'SHOW_DEBUG' )) define( 'SHOW_DEBUG', false ) ;
if( !defined( 'SHOW_DEBUG_SERVER' )) define( 'SHOW_DEBUG_SERVER', false ) ;
if( !defined( 'SHOW_DEBUG_ENV' )) define( 'SHOW_DEBUG_ENV', false ) ;

# Internationalization

if( !defined( 'I18N_DEFAULT_LANGUAGE' )) define( 'I18N_DEFAULT_LANGUAGE', 'en' ) ;
if( !defined( 'I18N_PREFERENCE_NAME' )) define( 'I18N_PREFERENCE_NAME', 'preferredLanguage' ) ;

# Presentation stuff
if( !defined( 'FRAMEWORK_DEFAULT_PRESENTER' )) define( 'FRAMEWORK_DEFAULT_PRESENTER', 'Smarty' ) ;
if( !defined( 'FRAMEWORK_BASE_MODULE_PATH' )) define ( 'FRAMEWORK_BASE_MODULE_PATH', '' ) ;
if( !defined( 'SMARTY_TMP_DIR' )) define('SMARTY_TMP_DIR', 'c:/tmp/smarty/emsd/');
if( !defined( 'SMARTY_COMPILE_DIR' )) define('SMARTY_COMPILE_DIR', SMARTY_TMP_DIR.'templates_c');
if( !defined( 'SMARTY_CACHE_DIR' )) define('SMARTY_CACHE_DIR', SMARTY_TMP_DIR.'cache');
if( !defined( 'SMARTY_CONFIG_DIR' )) define('SMARTY_CONFIG_DIR',SMARTY_TMP_DIR.'config');
if( !defined( 'SMARTY_TEMPLATE_PATH' )) define('SMARTY_TEMPLATE_PATH', APPLICATION_BASE_PATH.'/Presentation/Smarty/');
if( !defined( 'SMARTY_TEMPLATE' )) define('SMARTY_TEMPLATE', 'Default');
if( !defined( 'SMARTY_DEFAULT_TEMPLATE_FILE' )) define('SMARTY_DEFAULT_TEMPLATE_FILE', 'page.tpl');
if( !defined( 'SMARTY_DEFAULT_EXCEL_FILE' )) define('SMARTY_DEFAULT_EXCEL_FILE', 'excel.tpl');
if( !defined( 'SMARTY_DEFAULT_REDIRECT_FILE' )) define('SMARTY_DEFAULT_REDIRECT_FILE', 'redirect.tpl');
if( !defined( 'SMARTY_INCLUDES_DIR' )) define('SMARTY_INCLUDES_DIR', SMARTY_TEMPLATE_PATH.'/Default/includes/');
if( !defined( 'SMARTY_DEBUGGING' )) define( 'SMARTY_DEBUGGING', false ) ;

if( !defined( 'EZPDF_DIR' )) define('EZPDF_DIR', 'C:/php/includes/ezpdf/');

# tablebuilder, searchBar and pager keys

if( !defined( 'TBUILDER_KEY_SORT' )) define( 'TBUILDER_KEY_SORT', 'sort' ) ;
if( !defined( 'TBUILDER_KEY_SORTDIR' )) define( 'TBUILDER_KEY_SORTDIR', 'dir' ) ;

if( !defined( 'SBAR_FORM_NAME' )) define( 'SBAR_FORM_NAME', 'search' ) ;
if( !defined( 'SBAR_KEY_SUBMIT' )) define( 'SBAR_KEY_SUBMIT', 'searchSubmit' ) ;
if( !defined( 'SBAR_VAL_SUBMIT' )) define( 'SBAR_VAL_SUBMIT', 'Search' ) ;
if( !defined( 'SBAR_KEY_RESET' )) define( 'SBAR_KEY_RESET', 'searchReset' ) ;
if( !defined( 'SBAR_VAL_RESET' )) define( 'SBAR_VAL_RESET', 'Reset' ) ;
if( !defined( 'SBAR_KEY_SEARCH_COLUMN' )) define( 'SBAR_KEY_SEARCH_COLUMN', 'search_column' ) ;
if( !defined( 'SBAR_KEY_SEARCH_0' )) define( 'SBAR_KEY_SEARCH_0', 'search_value_0' ) ;
if( !defined( 'SBAR_KEY_SEARCH_1' )) define( 'SBAR_KEY_SEARCH_1', 'search_value_1' ) ;

if( !defined( 'PAGER_KEY_PAGE' )) define( 'PAGER_KEY_PAGE', 'page' ) ;
if( !defined( 'PAGER_KEY_LIMIT' )) define( 'PAGER_KEY_LIMIT', 'limit' ) ;

# Data/DB related stuff

if( !defined( 'DSN_MSSQL' )) define('DSN_MSSQL', 'mssql');
if( !defined( 'DSN_MYSQL' )) define('DSN_MYSQL', 'mysql');
if( !defined( 'DSN_OCI' )) define('DSN_OCI', 'oci8');

if ( !defined( 'LINE_END_MSSQL' )) define('LINE_END_MSSQL', "\n");
if ( !defined( 'LINE_END_MYSQL' )) define('LINE_END_MYSQL', ";\n");
if ( !defined( 'LINE_END_OCI' )) define('LINE_END_OCI', ";\n");
if ( !defined( 'DEFAULT_SQL_LINE_END' )) define( 'DEFAULT_SQL_LINE_END', '') ;

if( !defined( 'DB_DATATYPE_KEY' )) define( 'DB_DATATYPE_KEY', 'key' ) ;
if( !defined( 'DB_DATATYPE_INTEGER' )) define( 'DB_DATATYPE_INTEGER', 'int' ) ;
if( !defined( 'DB_DATATYPE_FLOAT' )) define( 'DB_DATATYPE_FLOAT', 'float' ) ;
if( !defined( 'DB_DATATYPE_DATETIME' )) define( 'DB_DATATYPE_DATETIME', 'date' ) ; 
if( !defined( 'DB_DATATYPE_DATE' )) define( 'DB_DATATYPE_DATE', 'date' ) ; 
if( !defined( 'DB_DATATYPE_TIME' )) define( 'DB_DATATYPE_TIME', 'time' ) ; 
if( !defined( 'DB_DATATYPE_TIMESTAMP' )) define( 'DB_DATATYPE_TIMESTAMP', 'timestamp' ) ; // unix timestamp
if( !defined( 'DB_DATATYPE_STRING_BASIC' )) define( 'DB_DATATYPE_STRING_BASIC', 'string' ) ;
if( !defined( 'DB_DATATYPE_STRING_EMAIL' )) define( 'DB_DATATYPE_STRING_EMAIL', 'email' ) ;
if( !defined( 'DB_DATATYPE_STRING_PHONE' )) define( 'DB_DATATYPE_STRING_PHONE', 'phone' ) ;  
if( !defined( 'DB_DATATYPE_STRING_URI' )) define( 'DB_DATATYPE_STRING_URI', 'uri' ) ;
if( !defined( 'DB_DATATYPE_STRING_XML' )) define( 'DB_DATATYPE_STRING_XML', 'xml' ) ;
if( !defined( 'DB_DATATYPE_CURRENCY' )) define( 'DB_DATATYPE_CURRENCY', 'money' ) ;
if( !defined( 'DB_DATATYPE_BLOB' )) define( 'DB_DATATYPE_BLOB', 'blob' ) ;
if( !defined( 'DB_DATATYPE_VIRTUAL' )) define( 'DB_DATATYPE_VIRTUAL', 'virtual' ) ; 

if( !defined( 'OCI_DATE_FORMAT' )) define( 'OCI_DATE_FORMAT', 'm/d/Y H:i:s' ) ;
if( !defined( 'OCI_DATE_FORMAT_STRING' )) define( 'OCI_DATE_FORMAT_STRING', 'MM/DD/YYYY HH24:MI:SS' ) ;

if( !defined( 'DECIMAL_MARKER' )) define( 'DECIMAL_MARKER', '.' ) ;

/**
* DEFAULT_VALIDATION_MODE
* 
* Default value is 'strict'.  Other valid values are 'require' and 'none'.  
* Invalid values are treated as 'require'.
*/
if( !defined( 'DEFAULT_VALIDATION_MODE' )) define( 'DEFAULT_VALIDATION_MODE', 'strict' ) ;

if( !defined( 'DB_AUTH_CLASS' )) define( 'DB_AUTH_CLASS', '' ) ;
if( !defined( 'DB_AUTH_USER_ATTR' )) define( 'DB_AUTH_USER_ATTR', 'username' ) ;
if( !defined( 'DB_AUTH_PASS_ATTR' )) define( 'DB_AUTH_PASS_ATTR', 'password' ) ;

if( !defined( 'DB_PERSISTENT_CONNECTION' )) define( 'DB_PERSISTENT_CONNECTION', false ) ;
if( !defined( 'MDB2_DISABLE_PORTABILITY' )) define( 'MDB2_DISABLE_PORTABILITY', false ) ;
if( !defined( 'MDB2_ENABLE_DELETE_COUNT' )) define( 'MDB2_ENABLE_DELETE_COUNT', false ) ;
if( !defined( 'MDB2_ENABLE_EMPTY_TO_NULL' )) define( 'MDB2_ENABLE_EMPTY_TO_NULL', false ) ;
if( !defined( 'MDB2_ENABLE_ERRORS' )) define( 'MDB2_ENABLE_ERRORS', false ) ;
if( !defined( 'MDB2_ENABLE_FIX_ASSOC_FIELD_NAMES' )) define( 'MDB2_ENABLE_FIX_ASSOC_FIELD_NAMES', false ) ;
if( !defined( 'MDB2_ENABLE_FIX_CASE' )) define( 'MDB2_ENABLE_FIX_CASE', false ) ;
if( !defined( 'MDB2_ENABLE_NUMROWS' )) define( 'MDB2_ENABLE_NUMROWS', false ) ;
if( !defined( 'MDB2_ENABLE_RTRIM' )) define( 'MDB2_ENABLE_RTRIM', false ) ;
if( !defined( 'KEYWORD_SQL_COUNT' )) define( 'KEYWORD_SQL_COUNT', "count" ) ;


if( !defined( 'PAGER_RECORDS_PER_PAGE' )) define( 'PAGER_RECORDS_PER_PAGE', 50 ) ;
if( !defined( 'PAGER_DEFAULT_PAGE' )) define( 'PAGER_DEFAULT_PAGE', 1 ) ;

# SMTP configuration options. See Pear::Mail documentation for details

if( !defined( 'SMTP_PARAMS' )) define( 'SMTP_PARAMS', serialize( array() )) ;

# for XML-RPC Client functions

if( !defined( 'XML_RPC_SERVER_HOST' )) define( 'XML_RPC_SERVER_HOST', '' ) ;
if( !defined( 'XML_RPC_SERVER_PATH' )) define( 'XML_RPC_SERVER_PATH', '' ) ;
if( !defined( 'XML_RPC_USERNAME' )) define( 'XML_RPC_USERNAME', '' ) ;
if( !defined( 'XML_RPC_PASSWORD' )) define( 'XML_RPC_PASSWORD', '' ) ;


# CONSTANTS USED BY Framework_Util_MailWrapper
if( !defined( 'EMAIL_TEST_MODE' )) define( 'EMAIL_TEST_MODE', false ) ;
if( !defined( 'EMAIL_TEST_MODE_RECIPIENT' )) define( 'EMAIL_TEST_MODE_RECIPIENT', null ) ;

?>
